package com.mediator.self;

import java.util.HashMap;

public class ConcretApplianceMediator extends ApplianceMediator{

    public HashMap<String,Appliance> applianceHashMap = new HashMap<>();
    private Appliance appliance;

    @Override
    public void register(Appliance appliance, String applianceName) {
        if(!applianceHashMap.containsKey(applianceName)){
            applianceHashMap.put(applianceName,appliance);
        }
    }

    @Override
    public void getMessage(int messageType, String applianceName) {
        appliance=applianceHashMap.get(applianceName);
        if(appliance instanceof AirCondition){
            AirCondition airCondition=(AirCondition) appliance;
            airCondition.openAirCondition();
        }else if (appliance instanceof Fan){
            Fan fan = (Fan) appliance;
            fan.openFan();
        }
    }

    @Override
    public void sendMessage() {

    }
}
